package com.knowif.backend.controller;

import com.knowif.search.SearchCondition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.knowif.backend.service.UserOrderService;
import com.knowif.pojo.UserOrder;
import com.knowif.system.model.RestBean;


@RestController
@RequestMapping("/wechat/order")
public class UserOrderController {
	
	@Autowired
	private UserOrderService userOrderService;
	
	
	/**
	 * @author: xingyao 
	 * @Description:  对订单进行评分
	 * @param orderId
	 * @param starNum
	 * @return
	 */
	@PostMapping("/orderStar")
	public RestBean<?> orderStar(@RequestBody UserOrder userOrder){
		return userOrderService.orderStar(userOrder);
	}

	/**
	 * @author: xh
	 * @Description:  查询订单
	 * @param searchCondition
	 * @return
	 */
	@PostMapping("/query")
	public RestBean<?> selectUserOrder(@RequestBody SearchCondition searchCondition){
		try {
			return userOrderService.selectOrder(searchCondition);
		} catch (Exception e) {
			return RestBean.buildError("系统繁忙");
		}
	}

	/**
	 * @author: xh
	 * @Description:  查询用户订单
	 * @param searchCondition
	 * @return
	 */
	@PostMapping("/queryOrderDetail")
	public RestBean<?> selectOrderDetail(@RequestBody SearchCondition searchCondition){
		try {
			return userOrderService.selectOrderDetail(searchCondition);
		} catch (Exception e) {
			return RestBean.buildError("系统繁忙");
		}
	}

}
